home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Files / XTND 1.3.6 / Application Examples / PascalSource / THINK ƒ / XTNDTextTranslator.p < prev   
Encoding:
Text File  |  1991-06-04  |  12.1 KB  |  302 lines  |  [TEXT/PJMM]

  1. {************************************************************************}
  2. {*                                                                        *}
  3. {*    XTNDTextTranslator.p                                                *}
  4. {*                                                                        *}
  5. {*    Header file for text translators.                                    *}
  6. {*                                                                        *}
  7. {*    Copyright © 1988-91 Claris Corporation                                *}
  8. {*    All Rights Reserved                                                    *}
  9. {*                                                                        *}
  10. {************************************************************************}
  11.  
  12. UNIT XTNDTextTranslator;
  13. INTERFACE
  14.     USES
  15.         dialogs, printing, XTNDInterface;
  16.  
  17.     CONST
  18.  
  19. { Directives to be passed to import translators }
  20.     importAcknowledge             = -1;    { Value set by a translator to acknowledge an action }
  21.  
  22.     importGetResources             = 0;
  23.     importInitAll                 = 1;
  24.  
  25.     importInitRightHeader         = 2;
  26.     importInitLeftHeader         = 3;
  27.     importInitHeader             = 4;
  28.  
  29.     importInitRightFooter         = 5;
  30.     importInitLeftFooter         = 6;
  31.     importInitFooter             = 7;
  32.  
  33.     importInitMain                 = 8;
  34.  
  35.     importInitFootnote             = 9;
  36.  
  37.     importGetText                 = 10;
  38.  
  39.     importCloseRightHeader         = 11;
  40.     importCloseLeftHeader         = 12;
  41.     importCloseHeader             = 13;
  42.  
  43.     importCloseRightFooter         = 14;
  44.     importCloseLeftFooter         = 15;
  45.     importCloseFooter             = 16;
  46.  
  47.     importCloseMain             = 17;
  48.  
  49.     importCloseFootnote         = 18;
  50.  
  51.     importCloseAll                 = 19;
  52.  
  53. { Directives to be passed to export translators }
  54.     exportAcknowledge             = -1;    { Set by translators to acknowledge certain directives }
  55.  
  56.     exportInitAll                 = 0;
  57.  
  58.     exportOpenRightHeader        = 1;
  59.     exportOpenLeftHeader         = 2;
  60.     exportOpenHeader             = 3;
  61.  
  62.     exportOpenRightFooter        = 4;
  63.     exportOpenLeftFooter         = 5;
  64.     exportOpenFooter             = 6;
  65.  
  66.     exportOpenFootnote             = 7;
  67.  
  68.     exportOpenMain                 = 8;
  69.  
  70.     exportWriteText                = 9;
  71.  
  72.     exportCloseRightHeader        = 10;
  73.     exportCloseLeftHeader        = 11;
  74.     exportCloseHeader             = 12;
  75.  
  76.     exportCloseRightFooter        = 13;
  77.     exportCloseLeftFooter        = 14;
  78.     exportCloseFooter            = 15;
  79.  
  80.     exportCloseFootnote            = 16;
  81.  
  82.     exportCloseMain                = 17;
  83.  
  84.     exportCloseAll                = 18;
  85.  
  86.     exportWriteResources        = 19;
  87.  
  88.  
  89. { Defines for CurrentStory }
  90.         rightHeaderStory = 1;
  91.         leftHeaderStory = 2;
  92.         headerStory = 3;
  93.         rightFooterStory = 4;
  94.         leftFooterStory = 5;
  95.         footerStory = 6;
  96.         footnoteStory = 7;
  97.         mainStory = 8;
  98.  
  99. { types of pages for headers/footers }
  100.         everyPage = 1;
  101.         leftPage = 2;
  102.         rightPage = 4;
  103.  
  104. { XTND 1.x reserved characters }
  105.         pageNumber = $02;    { Current page number character }
  106.         footnoteChar = $03;    { Footnote character in the footnote }
  107.         floatingPict = $04;    { Floating picture marker }
  108.         footnoteMark = $05;    { Footnote character in the text }
  109.         mergeBreak = $06;    { Mail merge document break }
  110.         hardReturn = $07;    { Hard return (does not create new paragraph) }
  111.         tabChar = $09;    { Tab character }
  112.         newColumn = $0B;    { Column break character }
  113.         newPage = $0C;    { Page break character }
  114.         returnChar = $0D;    { Paragraph break character }
  115.         shortDateChar = $15;    { Assorted date characters }
  116.         abbrDateChar = $16;
  117.         longDateChar = $17;
  118.         dayAbbrDateChar = $18;    { Date characters with day of week included }
  119.         dayLongDateChar = $19;
  120.         timeChar = $1A;    { Time character }
  121.         softHyphen = $1F;    { Discretionary hyphen character }
  122.  
  123.     { Other character values }
  124.         enterChar = $03;
  125.  
  126.     { XTND 1.x limits }
  127.         numParaFmts = 9;            { Number of fields in a paragraph specification }
  128.         maxCols = 10;            { Maximum number of columns allowed }
  129.         maxTabs = 20;            { Maximum number of tabs allowed }
  130.         minGutter = $00030000;    { (minimum gutter) 3 points as a Fixed number }
  131.         maxGutter = $01200000;    { (maximum gutter) 288 points as a Fixed number }
  132.         dfltGutter = $00090000;    { (default gutter) 9 points as a Fixed number }
  133.  
  134. { XTND 1.x text styles }
  135.         textPlain = $0000;
  136.         textSuperScript = $0020;
  137.         textSubScript = $0040;
  138.         textNonbreaking = $0080;
  139.         textSuperior = $0100;
  140.         textStrikeThru = $0200;
  141.         textAllCaps = $0400;
  142.         textSmallCaps = $0800;
  143.         textWordUnderline = $1000;
  144.         textDoubleUnderline = $2000;
  145.         textLowerCase = $4000;
  146.  
  147. { XTND 1.x justification/tab alignment values }
  148.         textLeft = 0;
  149.         textCenter = 1;
  150.         textRight = 2;
  151.         textJustified = 3;        { For text }
  152.         textDecimal = 3;        { For tabs }
  153.  
  154. { XTND 1.x text color values }
  155.         textWhite = 0;
  156.         textBlack = 1;
  157.         textRed = 2;
  158.         textGreen = 3;
  159.         textBlue = 4;
  160.         textCyan = 5;
  161.         textMagenta = 6;
  162.         textYellow = 7;
  163.         textOtherColor = 8;
  164.  
  165.     TYPE
  166.     { Tab specifications record.  The tab array contains 20 of these.}
  167.         TabSpec = RECORD
  168.                 tabJust: SignedByte;    { Tab justification (left, right, center, aligned) }
  169.                 tabLead: SignedByte;    { Tab leader character (default is space) }
  170.                 tabIndent: Fixed;        { Tab indent in points from left page margin }
  171.                 decAlign: SignedByte;    { Tab alignment character (usually period) }
  172.             END;
  173.         TabSpecArray = ARRAY[0..19] OF TabSpec;
  174.  
  175.  
  176.     { The pictMisc data structure is used to import a quickdraw picture }
  177.         pictMiscHdl = ^pictMiscPtr;
  178.         pictMiscPtr = ^pictMisc;
  179.         pictMisc = RECORD
  180.                 thePicture: PicHandle;        { handle to the quickdraw picture }
  181.                 pictSize: LongInt;        { Size of associated picture }
  182.                 destRect: Rect;            { Used for scaling the picture, OrigRect will be scaled to this rect }
  183.                 origRect: Rect;            { Used for cropping the picture, pictRect will be cropped to this rect }
  184.                 reserved: PACKED ARRAY[1..38] OF Byte;    { Reserved, fill with zeros }
  185.             END;
  186.  
  187.     { Paragraph format record.  The ParaFormats array contains 9 Fixed values }
  188.     ParaFormat        = Fixed;
  189.     ParaFormats        = ARRAY [0..8] OF ParaFormat;
  190.  
  191.     { This is the parameter block for passing information to an import translator }
  192.         ImportParmBlkPtr = ^ImportParmBlock;
  193.         ImportParmBlock = RECORD
  194.                 textBuffer: Ptr;        { Pointer to 256 bytes of data }
  195.                 directive: INTEGER;    { Indicates the action to be performed }
  196.                 result: OSErr;        { Return code, 0 if successful, error code otherwise }
  197.                 textLength: LONGINT;    { Number of characters of information being returned }
  198.                 translatorState: INTEGER;    { Available for use by the translator }
  199.                 refNum: INTEGER;    { Reference number of the fork to be read by the translator }
  200.                 txtFace: INTEGER;    { Current text face }
  201.                 txtSize: INTEGER;    { Current text font size }
  202.                 txtFont: INTEGER;    { Current text font family number }
  203.                 txtColor: INTEGER;    { Current text color (MacWrite II color value) }
  204.                 txtJust: INTEGER;    { Justification of this text }
  205.                 unused1: INTEGER;    { Must be zero }
  206.                 paraFmts: ^ParaFormats;    { Pointer to this paragraph's format array }
  207.                 tabs: ^TabSpecArray;{ Pointer to this paragraph's tab array }
  208.                 unused2: BOOLEAN;    { Currently unused }
  209.                 numCols: SignedByte;    { Number of columns expected }
  210.                 currentStory: INTEGER;    { Header,Footer,Main Body, etc. }
  211.                 miscData: LONGINT;    { For importing pictures, etc. }
  212.                 storyHeight: INTEGER;    { Height of header,footer, etc. }
  213.                 decimalChar: Char;        { Default char to align decimal tab on }
  214.                 autoHyphenate: BOOLEAN;    { If TRUE, auto hyphenation is on }
  215.                 printRecord: THPrint;    { Print record, if one is used, otherwise NIL }
  216.                 topMargin: Fixed;        { Document top margin }
  217.                 bottomMargin: Fixed;    { Document bottom margin }
  218.                 leftMargin: Fixed;        { Document left margin }
  219.                 rightMargin: Fixed;        { Document right margin }
  220.                 gutter: Fixed;            { Space between columns }
  221.                 startPageNum: INTEGER;    { Starting page number }
  222.                 startFootnoteNum: INTEGER;    { starting footnote number }
  223.                 footnoteText: Ptr;        { If not empty, text associated with footnote, else auto }
  224.                 rulerShowing: BOOLEAN;    { If TRUE, ruler is showing }
  225.                 doubleSided: BOOLEAN;    { If TRUE, document has Left/Right pages }
  226.                 titlePage: BOOLEAN;    { If TRUE, document has a title page (with no headers/footers) }
  227.                 endnotes: BOOLEAN;    { If TRUE, footnotes are displayed as endnotes }
  228.                 showInvisibles: BOOLEAN;    { If TRUE, invisible characters will be displayed }
  229.                 showPageGuides: BOOLEAN;    { If TRUE, page guides will be displayed }
  230.                 showPictures: BOOLEAN;    { If TRUE, pictures will be displayed }
  231.                 autoFootnotes: BOOLEAN;    { If TRUE, footnotes will be numbered automatically }
  232.                 pagePoint: Point;        { Position for page number within header/footer }
  233.                 datePoint: Point;        { Position for date character within header/footer }
  234.                 timePoint: Point;        { Position for time character within header/footer }
  235.                 globalHandle: Handle;        { Handle to translator globals, if needed }
  236.                 smartQuotes: BOOLEAN;    { If TRUE, smart quotes will be used }
  237.                 fractCharWidths: BOOLEAN;    { If TRUE, fractional character widths will be used }
  238.                 hRes: INTEGER;    { The horizontal resolution of this document (default is 72) }
  239.                 vRes: INTEGER;    { The vertical resolution of this document (default is 72) }
  240.                 windowRect: Rect;        { May be used to specify document window placement and size }
  241.                 theReply: SFReply;    { Standard reply record describing the file being translated }
  242.                 thisTranslator: TransDescribe;{ TransDescribe record describing this translator }
  243.             END;
  244.  
  245.  
  246.     { This is the parameter block for passing information to an export translator.}
  247.         ExportParmBlkPtr = ^ExportParmBlock;
  248.         ExportParmBlock = RECORD
  249.                 directive: SignedByte;    { Indicates the action to be performed }
  250.                 filler1: SignedByte;    { explicit padding }
  251.                 result: ^OSErr;        { Pointer to return code, 0 if successful, error code otherwise }
  252.                 refNum: ^INTEGER;    { Pointer to reference number of the file being written by the translator }
  253.                 textLength: ^LONGINT;    { Pointer to number of characters being exported }
  254.                 globalHandle: Handle;        { Do not change this value }
  255.                 reserved1: LONGINT;    { Do not change this value }
  256.                 textBuffer: Handle;        { Handle to the text being exported }
  257.                 txtFace: ^INTEGER;    { Pointer to the current text face }
  258.                 txtSize: ^INTEGER;    { Pointer to the current text font size }
  259.                 txtFont: ^INTEGER;    { Pointer to the current text font family number }
  260.                 txtColor: ^SignedByte;{ Pointer to the current text color (MacWrite II color value) }
  261.                 txtJust: ^INTEGER;    { Pointer to the justification of this text }
  262.                 paraFmts: ^ParaFormats;        { Pointer to this paragraph's format array }
  263.                 tabs: ^TabSpecArray;{ Pointer to this paragraph's tab array }
  264.                 thePicture: PicHandle;    { Handle to a quickdraw picture }
  265.                 pictRect: Rect;        { Rectangle describing the display rect of the above picture }
  266.                 headerStatus: INTEGER;    { Shows if header is on left/right/every page }
  267.                 footerStatus: INTEGER;    { Shows if footer is on left/right/every page }
  268.                 currentStory: INTEGER;    { Header, Footer, Main Body, etc. }
  269.                 numCols: INTEGER;    { Number of columns in document }
  270.                 topMargin: Fixed;        { Document top margin }
  271.                 bottomMargin: Fixed;        { Document bottom margin }
  272.                 leftMargin: Fixed;        { Document left margin }
  273.                 rightMargin: Fixed;        { Document right margin }
  274.                 gutter: Fixed;        { Space between columns }
  275.                 totalCharCount: LONGINT;    { Total number of chars in document (for Word 3.0) }
  276.                 footnoteOffset: LONGINT;    { If current story is a footnote, its offset in doc }
  277.                 footnoteText: StringPtr;    { If !autoFootnotes, text for footnote (Pascal String) }
  278.                 startPageNum: INTEGER;    { Starting page number }
  279.                 startFootnoteNum: INTEGER;    { Starting footnote number }
  280.                 rulerShowing: BOOLEAN;    { if TRUE, ruler is showing }
  281.                 doubleSided: BOOLEAN;    { if TRUE, document has Left/Right pages }
  282.                 titlePage: BOOLEAN;    { If TRUE, document has a title page (with no headers/footers) }
  283.                 endnotes: BOOLEAN;    { If TRUE, footnotes are displayed as endnotes }
  284.                 showInvisibles: BOOLEAN;    { If TRUE, invisible characters are displayed }
  285.                 showPageGuides: BOOLEAN;    { If TRUE, page guides are displayed }
  286.                 showPictures: BOOLEAN;    { If TRUE, pictures are displayed }
  287.                 autoFootnotes: BOOLEAN;    { If TRUE, footnotes are numbered automatically }
  288.                 footnotesExist: BOOLEAN;    { If TRUE, footnotes are being exported }
  289.                 printRecord: THPrint;    { Print record for this document }
  290.                 pagePoint: Point;        { Point where page number is displayed in header or footer }
  291.                 datePoint: Point;        { Point where date character is displayed in header or footer }
  292.                 timePoint: Point;        { Point where time character is displayed in header or footer }
  293.                 smartQuotes: BOOLEAN;    { If TRUE, SmartQuotes are turned on }
  294.                 fractCharWidths: BOOLEAN;    { If TRUE, fractional character widths are turned on }
  295.                 hRes: INTEGER;    { The horizontal resolution of this document }
  296.                 vRes: INTEGER;    { The vertical resolution of this document }
  297.                 windowRect: Rect;        { Rectangle specifying document window placement and size }
  298.                 theReply: SFReply;    { Standard reply record describing the file being written }
  299.                 thisTranslator: TransDescribe;{ TransDescribe record describing this translator }
  300.             END;
  301. IMPLEMENTATION
  302. END.